package com.gzj.environment.module.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzj.environment.model.system.criteria.UserCriteria;
import com.gzj.environment.model.system.entity.User;
import com.gzj.environment.model.system.vo.UserVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @description:
 * @author: tsing
 * @create: 2021-01-21 22:19
 */
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据用户查找用户信息
     * @param username 用户名
     * @return
     */
    @Select("select id, username, mobile, password, role_id from sys_user where username = #{username} and deleted = 0")
    User findByUsername(@Param("username") String username);

    /**
     * 根据手机号查找用户信息
     * @param mobile 手机号
     * @return
     */
    @Select("select id, username, mobile, role_id from sys_user where mobile = #{mobile} and deleted = 0")
    User findByMobile(@Param("mobile") String mobile);

    /**
     * 分页条件查询用户信息
     * @param pageInfo 分页信息
     * @param criteria 条件对象
     * @return
     */
    Page<UserVo> pageList(@Param("page") Page<UserVo> pageInfo, @Param("criteria") UserCriteria criteria);
}
